import { createStore, createLogger } from 'vuex'
import createPersistedState from 'vuex-persistedstate'
// import * as Cookies from 'js-cookie'
import user from './modules/user'
import cart from './modules/cart'

export default createStore({
  state: {
  },
  mutations: {
  },
  actions: {
  },
  getters: {
  },
  modules: {
    user,
    cart
  },
  plugins: [
    // 默认把存储方式存储到cookie中去
    createPersistedState({
      // 默认存储到本地
      key: 'rabbit-key',
      paths: ['user', 'cart']
      // storage: {
      //   getItem: (key) => Cookies.get(key),
      //   setItem: (key, value) =>
      //     Cookies.set(key, value, { expires: 3, secure: true }),
      //   removeItem: (key) => Cookies.remove(key)
      // }
    }),
    createLogger()

  ]
})
